<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, max-age=0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' https: data: blob:; img-src 'self' https: data: blob: *; connect-src 'self' https: *;">
    <title>老非FS资料库</title>
    <link rel="stylesheet" href="styles.css?v=202508311400">
    <!-- 使用本地图标字体，避免CDN问题 -->
    <!-- 使用国内CDN，提高访问速度 -->
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" crossorigin="anonymous" referrerpolicy="no-referrer">
    
    <!-- Service Worker 注册 -->
    <script>
        if ('serviceWorker' in navigator) {
            window.addEventListener('load', () => {
                navigator.serviceWorker.register('./sw.js?v=202508311400')
                    .then((registration) => {
                        console.log('Service Worker registered with scope:', registration.scope);
                        // 安全的调试信息调用
                        if (typeof addDebugInfo === 'function') {
                            addDebugInfo('Service Worker注册成功: ' + registration.scope);
                        }
                        
                        // 检查更新
                        registration.addEventListener('updatefound', () => {
                            console.log('Service Worker update found');
                            if (typeof addDebugInfo === 'function') {
                                addDebugInfo('Service Worker发现更新');
                            }
                        });
                        
                        // 监听控制器变化
                        navigator.serviceWorker.addEventListener('controllerchange', () => {
                            console.log('Service Worker controller changed');
                            if (typeof addDebugInfo === 'function') {
                                addDebugInfo('Service Worker控制器已更新');
                            }
                        });
                    })
                    .catch((error) => {
                        console.log('Service Worker registration failed:', error);
                        if (typeof addDebugInfo === 'function') {
                            addDebugInfo('Service Worker注册失败: ' + error.message);
                        }
                    });
            });
        } else {
            if (typeof addDebugInfo === 'function') {
                addDebugInfo('浏览器不支持Service Worker');
            }
        }
    </script>
</head>
<body>
    <!-- 头部区域 -->
    <header class="header">
        <div class="header-content">
            <h1 class="main-title">街头篮球资料库</h1>
            <div class="title-underline"></div>
            <div class="header-bottom">
                <p class="powered-by">Powered by 老非</p>
                <div class="contact-tag">
                    <i class="fas fa-comments"></i>
                    <span>laofei90186</span>
                </div>
            </div>
            <div class="refresh-tip-header">
                <i class="fas fa-exclamation-triangle"></i>
                <span>点击右上角三个点➡️刷新获取最新版</span>
            </div>
            
            <!-- 调试信息 -->
            <div id="debug-info" style="background: rgba(0,0,0,0.8); color: white; padding: 10px; margin: 10px; border-radius: 5px; font-size: 12px; display: none;">
                <div id="debug-content">调试信息加载中...</div>
                <div style="margin-top: 5px;">
                    <button onclick="toggleDebug()" style="background: #007bff; color: white; border: none; padding: 5px 10px; border-radius: 3px; margin-right: 5px;">切换调试</button>
                    <button onclick="checkCacheStatus()" style="background: #28a745; color: white; border: none; padding: 5px 10px; border-radius: 3px; margin-right: 5px;">检查缓存</button>
                    <button onclick="clearAllCaches()" style="background: #dc3545; color: white; border: none; padding: 5px 10px; border-radius: 3px;">清除缓存</button>
                </div>
            </div>
            

            

        </div>
    </header>

    <!-- 主要内容区域 -->
    <main class="main-content">
        <!-- 主导航按钮 -->
        <div class="nav-container">
            <div class="nav-buttons">
                <button class="nav-btn active" data-section="gallery">
                    <i class="fas fa-images"></i>
                    <span>超特图鉴</span>
                </button>
                <button class="nav-btn" data-section="characters">
                    <i class="fas fa-running"></i>
                    <span>超特动作</span>
                </button>
                <button class="nav-btn" data-section="ranking">
                    <i class="fas fa-trophy"></i>
                    <span>职业排名</span>
                </button>
                <button class="nav-btn" data-section="account">
                    <i class="fas fa-user-circle"></i>
                    <span>FS账号</span>
                </button>
                <button class="nav-btn" data-section="courses">
                    <i class="fas fa-graduation-cap"></i>
                    <span>老非课程</span>
                </button>
                <button class="nav-btn" data-section="skills">
                    <span>实用技巧</span>
                </button>
                <button class="nav-btn" data-section="events">
                    <span>活动</span>
                </button>

            </div>
        </div>

        <!-- 角色代次筛选按钮 -->
        <div class="filter-container">
            <div class="filter-buttons">
                <button class="filter-btn" data-generation="1">
                    <i class="fas fa-bolt"></i>
                    <span>1代超特</span>
                </button>
                <button class="filter-btn" data-generation="2">
                    <i class="fas fa-bolt"></i>
                    <span>2代超特</span>
                </button>
                <button class="filter-btn" data-generation="3">
                    <i class="fas fa-bolt"></i>
                    <span>3代超特</span>
                </button>
                <button class="filter-btn" data-generation="3_5">
                    <i class="fas fa-bolt"></i>
                    <span>3.5代超特</span>
                </button>
                <button class="filter-btn" data-generation="4">
                    <i class="fas fa-bolt"></i>
                    <span>4代超特</span>
                </button>
                <button class="filter-btn" data-generation="4_5">
                    <i class="fas fa-bolt"></i>
                    <span>4.5代超特</span>
                </button>
                <button class="filter-btn" data-generation="5">
                    <i class="fas fa-bolt"></i>
                    <span>5代超特</span>
                </button>
                <button class="filter-btn" data-generation="5.5">
                    <i class="fas fa-bolt"></i>
                    <span>5.5代超特</span>
                </button>
                <button class="filter-btn" data-generation="6">
                    <i class="fas fa-bolt"></i>
                    <span>6代超特</span>
                </button>
                <button class="filter-btn" data-generation="6.5">
                    <i class="fas fa-bolt"></i>
                    <span>6.5代超特</span>
                </button>
                <button class="filter-btn" data-generation="7">
                    <i class="fas fa-bolt"></i>
                    <span>7代超特</span>
                </button>
                <button class="filter-btn" data-generation="7.5">
                    <i class="fas fa-bolt"></i>
                    <span>7.5代超特</span>
                </button>
                <button class="filter-btn" data-generation="8">
                    <i class="fas fa-bolt"></i>
                    <span>8代超特</span>
                </button>
                <button class="filter-btn active" data-generation="9">
                    <i class="fas fa-bolt"></i>
                    <span>9代超特</span>
                </button>
            </div>
        </div>

        <!-- 移除刷新提示 -->
        <!-- <div id="refresh-tip" class="refresh-tip" style="display: none;">
            <p>检测到新版本，请下拉刷新页面</p>
        </div> -->
        
        <!-- 内容显示区域 -->
        <div class="content-area">
            <div id="gallery-section" class="content-section active">
                <h2>超特图鉴</h2>
                <div class="gallery-grid" id="gallery-grid">
                    <!-- 图鉴卡片将在这里动态生成 -->
                </div>
            </div>
            
            <div id="characters-section" class="content-section">
                <h2>超特动作</h2>
                <div class="characters-grid" id="characters-grid">
                    <!-- 角色卡片将在这里动态生成 -->
                </div>
            </div>

            <div id="ranking-section" class="content-section">
                <h2>职业排名</h2>
                <div class="ranking-tabs">
                    <button class="ranking-tab active" data-ranking="c">
                        <i class="fas fa-user"></i>
                        <span>C排名</span>
                    </button>
                    <button class="ranking-tab" data-ranking="pf">
                        <i class="fas fa-user"></i>
                        <span>PF排名</span>
                    </button>
                    <button class="ranking-tab" data-ranking="pg">
                        <i class="fas fa-user"></i>
                        <span>PG排名</span>
                    </button>
                </div>
                <div class="ranking-content">
                    <div id="c-ranking" class="ranking-item active">
                        <img src="" alt="C排名" class="ranking-image" id="c-ranking-image">
                    </div>
                    <div id="pf-ranking" class="ranking-item">
                        <img src="" alt="PF排名" class="ranking-image" id="pf-ranking-image">
                    </div>
                    <div id="pg-ranking" class="ranking-item">
                        <img src="" alt="PG排名" class="ranking-image" id="pg-ranking-image">
                    </div>
                </div>
            </div>

            <div id="skills-section" class="content-section">
                <h2>实用技巧</h2>
                <p>实用技巧内容将在这里显示</p>
            </div>

            <div id="events-section" class="content-section">
                <h2>活动</h2>
                <p>活动内容将在这里显示</p>
            </div>

            <div id="account-section" class="content-section">
                <div class="account-container">
                    <div class="account-module">
                        <div class="module-header">
                            <i class="fas fa-store"></i>
                            <h3>查看老非FS账号店铺</h3>
                        </div>
                        <div class="module-content">
                            <p class="store-desc">浏览老非的FS账号店铺，选择心仪的账号</p>
                            <button class="store-btn" onclick="openStore()">
                                <i class="fas fa-external-link-alt"></i>
                                <span>进入店铺</span>
                            </button>
                        </div>
                    </div>
                    
                    <div class="account-module">
                        <div class="module-header">
                            <i class="fas fa-user-check"></i>
                            <h3>老非帮选号+调试服务</h3>
                        </div>
                        <div class="module-content">
                            <p class="service-desc">专业帮您选择最适合的FS账号，并提供调试服务</p>
                            <div class="contact-info">
                                <div class="wechat-section">
                                    <label>微信号：</label>
                                    <div class="wechat-display">
                                        <span id="wechat-number">laofei90186</span>
                                        <button class="copy-btn" onclick="copyWechat()">
                                            <i class="fas fa-copy"></i>
                                            <span>复制</span>
                                        </button>
                                    </div>
                                </div>
                                <p class="copy-tip">点击复制按钮即可复制微信号，添加好友咨询详情</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div id="courses-section" class="content-section">
                <h2>老非课程</h2>
                <div class="courses-container">
                    <div class="course-category">
                        <h3><i class="fas fa-star" style="color: #22c55e;"></i> 适合内线的课程</h3>
                        <div class="course-grid">
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">TT综合打法</div>
                                        <div class="course-banner-subtitle">0基础学习TT阵容 (PF+C+PG通用)</div>
                                        <div class="course-banner-desc">1.了解当前版本主流打法进位票位等</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非TT阵容打法课 (PFCPG通用)</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">盖帽教学</div>
                                        <div class="course-banner-subtitle">盖帽的快乐谁不想多多体验</div>
                                        <div class="course-banner-desc">1.冒位冒点老非全解析</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">街球老非盖帽教学TT篇 (已更新9代罗卡盖帽教学)</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">躲吸与牵制</div>
                                        <div class="course-banner-subtitle">牵制躲吸做得好好友少不了</div>
                                        <div class="course-banner-desc">1.了解大梦/大力的范围与机制</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非《躲吸与牵制教学》含躲大力和牵制吸人全流程</div>
                                    <div class="course-price">¥ 159.00</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">进攻技巧/碎步</div>
                                        <div class="course-banner-subtitle">谁不想打帅球秀操作呢?</div>
                                        <div class="course-banner-desc">1.各类碎步共34+个,老非精心总结</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非教学《TT阵容34个进攻技巧》含各类碎步及按键逐...</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">篮板课程</div>
                                        <div class="course-banner-subtitle">得篮板者得天下 篮板学习是没有尽</div>
                                        <div class="course-banner-desc">1.了解板位板点高标等基础知识</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非街球教学视频篮板篇</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">跑扣课</div>
                                        <div class="course-banner-subtitle">为什么玩PF? 我是为了这个扣篮</div>
                                        <div class="course-banner-desc">1.了解起扣的机制原理</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非街球教学跑扣篇</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">精准传球教程</div>
                                        <div class="course-banner-subtitle">做一个有"QE"指定传球的内线</div>
                                        <div class="course-banner-desc">1.精准传球技巧详解</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">街球老非精准传球教学 (不包含一条直线传球)</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="course-category">
                        <h3><i class="fas fa-star" style="color: #22c55e;"></i> 适合PG的课程</h3>
                        <div class="course-grid">
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">TT综合打法</div>
                                        <div class="course-banner-subtitle">0基础学习TT阵容(PF+C+PG通用)</div>
                                        <div class="course-banner-desc">1.了解当前版本主流打法进位票位等</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非TT阵容打法课(PFCPG通用)</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">盖帽教学</div>
                                        <div class="course-banner-subtitle">盖帽的快乐谁不想多多体验</div>
                                        <div class="course-banner-desc">1.冒位冒点毛非全解析</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">街球老非盖帽教学TT篇(已更新9代罗卡盖帽教学)</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">躲吸与牵制</div>
                                        <div class="course-banner-subtitle">牵制躲吸做得好好友少不了</div>
                                        <div class="course-banner-desc">1.了解大梦/大力的范围与机制</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非《躲吸与牵制教学》含躲大力和牵制吸人全流程</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">篮板课程</div>
                                        <div class="course-banner-subtitle">得篮板者得天下 篮板学习是没有尽</div>
                                        <div class="course-banner-desc">1.了解板位板点高标等基础知识</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非街球教学视频篮板篇</div>
                                </div>
                            </div>
                            
                            <div class="course-card" onclick="openCourse('https://h5.htknow.com/#/pages/teacher/home/home?id=46187&uid=152933534&code=0116xOkl2ALUcg43vonl231yvR06xOkN&state=snsapi_base')">
                                <div class="course-banner">
                                    <div class="course-banner-content">
                                        <div class="course-banner-title">PG跑位</div>
                                        <div class="course-banner-subtitle">PG作为球队大脑必须讲究跑位</div>
                                        <div class="course-banner-desc">1.不同开局对位站位老非给出详细胞位路线</div>
                                        <div class="course-tag">专栏</div>
                                    </div>
                                </div>
                                <div class="course-info">
                                    <div class="course-title">老非《TT阵容PG跑位教学》基础版</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div id="admin-section" class="content-section">
                <h2>管理端</h2>
                <p>管理端内容将在这里显示</p>
            </div>
        </div>
    </main>

    <!-- 全屏显示容器 -->
    <div id="fullscreen-overlay" class="fullscreen-overlay">
        <img id="fullscreen-image" class="fullscreen-image" src="" alt="">
    </div>

    <script src="script.js?v=202508311400"></script>
    
    <!-- 微信浏览器特殊处理 -->
    <script>
        // 微信浏览器特殊处理
        (function() {
            var isWeChat = /MicroMessenger/i.test(navigator.userAgent);
            var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
            var isNewUser = !localStorage.getItem('hasVisited');
            
            // 安全的调试信息函数
            function safeDebugInfo(message) {
                try {
                    if (typeof addDebugInfo === 'function') {
                        addDebugInfo(message);
                    } else {
                        console.log('Debug:', message);
                    }
                } catch (e) {
                    console.log('Debug:', message);
                }
            }
            
            console.log('浏览器检测:', '微信:', isWeChat, 'iOS:', isIOS, '新用户:', isNewUser);
            safeDebugInfo('浏览器检测: 微信=' + isWeChat + ', iOS=' + isIOS + ', 新用户=' + isNewUser);
            
            // 标记用户已访问
            if (isNewUser) {
                localStorage.setItem('hasVisited', 'true');
                safeDebugInfo('新用户首次访问');
            }
            
            // 强制清除缓存 - 更激进的方法
            function forceClearCache() {
                // 新用户不清除缓存，避免影响首次加载
                if (isNewUser) {
                    safeDebugInfo('新用户，跳过缓存清除');
                    return;
                }
                
                // 清除localStorage和sessionStorage
                localStorage.clear();
                sessionStorage.clear();
                safeDebugInfo('localStorage和sessionStorage已清除');
                
                // 清除所有缓存
                if ('caches' in window) {
                    caches.keys().then(function(names) {
                        for (var i = 0; i < names.length; i++) {
                            caches.delete(names[i]);
                            console.log('缓存已清除:', names[i]);
                            safeDebugInfo('缓存已清除: ' + names[i]);
                        }
                    });
                }
                
                // 强制刷新页面（仅在必要时）
                var lastVisit = localStorage.getItem('lastVisit');
                var currentTime = new Date().getTime();
                if (!lastVisit || (currentTime - parseInt(lastVisit)) > 300000) { // 5分钟
                    localStorage.setItem('lastVisit', currentTime);
                    safeDebugInfo('页面可能需要强制刷新');
                }
            }
            
            // Service Worker状态检查
            if ('serviceWorker' in navigator) {
                navigator.serviceWorker.getRegistrations().then(function(registrations) {
                    console.log('当前Service Worker数量:', registrations.length);
                    safeDebugInfo('当前Service Worker数量: ' + registrations.length);
                    for (var i = 0; i < registrations.length; i++) {
                        console.log('Service Worker状态:', registrations[i].active ? 'active' : 'inactive');
                        safeDebugInfo('Service Worker状态: ' + (registrations[i].active ? 'active' : 'inactive'));
                    }
                });
            }
            
            // 执行强制清除缓存
            forceClearCache();
            
            // 预加载关键资源
            function preloadResources() {
                safeDebugInfo('开始预加载关键资源');
                
                // 预加载CSS
                var cssLink = document.createElement('link');
                cssLink.rel = 'preload';
                cssLink.as = 'style';
                cssLink.href = 'styles.css?v=202508311400';
                document.head.appendChild(cssLink);
                
                // 预加载JS
                var jsLink = document.createElement('link');
                jsLink.rel = 'preload';
                jsLink.as = 'script';
                jsLink.href = 'script.js?v=202508311400';
                document.head.appendChild(jsLink);
                
                // 预加载关键图片
                var imageUrls = [
                    'https://laofei-1259209256.cos.ap-nanjing.myqcloud.com/gallery/超特图鉴.png',
                    'https://laofei-1259209256.cos.ap-nanjing.myqcloud.com/ranking/C排名.png'
                ];
                
                for (var i = 0; i < imageUrls.length; i++) {
                    var img = new Image();
                    img.src = imageUrls[i] + '?v=' + Date.now();
                    img.onload = function() {
                        safeDebugInfo('图片预加载成功: ' + this.src);
                    };
                    img.onerror = function() {
                        safeDebugInfo('图片预加载失败: ' + this.src);
                    };
                }
                
                safeDebugInfo('预加载资源设置完成');
            }
            
            // 新用户执行预加载
            if (isNewUser) {
                preloadResources();
            }
            
            // HTTPS强制检查（仅对网络访问生效）
            if (location.protocol !== 'https:' && location.hostname !== 'localhost' && location.protocol !== 'file:') {
                safeDebugInfo('检测到非HTTPS协议，重定向到HTTPS');
                location.replace('https:' + location.href.substring(location.protocol.length));
                return;
            }
            
            // CORS检查
            function checkCORS() {
                var testImage = new Image();
                testImage.onload = function() {
                    safeDebugInfo('CORS检查通过 - 图片加载正常');
                };
                testImage.onerror = function() {
                    safeDebugInfo('CORS检查失败 - 图片加载失败');
                    // 移除微信警告提示
                };
                testImage.src = 'https://laofei-1259209256.cos.ap-nanjing.myqcloud.com/gallery/超特图鉴.png?v=' + new Date().getTime();
            }
            
            if (isWeChat) {
                console.log('微信浏览器检测到，应用特殊处理');
                safeDebugInfo('微信浏览器检测到，应用特殊处理');
                
                // 新用户特殊处理
                if (isNewUser) {
                    safeDebugInfo('新用户微信浏览器特殊处理');
                    // 延迟初始化，确保页面完全加载
                    setTimeout(function() {
                        initializePageFunctions();
                    }, 2000);
                }
                
                // 页面功能初始化函数
                function initializePageFunctions() {
                    var success = true;
                    
                    if (typeof initializeNavigation === 'function') {
                        try {
                            initializeNavigation();
                            safeDebugInfo('导航初始化完成');
                        } catch (e) {
                            safeDebugInfo('导航初始化失败: ' + e.message);
                            success = false;
                        }
                    }
                    
                    if (typeof initializeFilters === 'function') {
                        try {
                            initializeFilters();
                            safeDebugInfo('筛选器初始化完成');
                        } catch (e) {
                            safeDebugInfo('筛选器初始化失败: ' + e.message);
                            success = false;
                        }
                    }
                    
                    if (typeof loadCharacters === 'function') {
                        try {
                            loadCharacters('9');
                            safeDebugInfo('角色加载完成');
                        } catch (e) {
                            safeDebugInfo('角色加载失败: ' + e.message);
                            success = false;
                        }
                    }
                    
                    if (!success) {
                        safeDebugInfo('部分功能初始化失败，3秒后重试');
                        setTimeout(function() {
                            initializePageFunctions();
                        }, 3000);
                    }
                }
                
                // 执行CORS检查
                setTimeout(function() {
                    checkCORS();
                }, 1000);
                
                // iOS微信特殊处理
                if (isIOS) {
                    console.log('iOS微信特殊处理');
                    safeDebugInfo('iOS微信特殊处理');
                    document.body.style.webkitOverflowScrolling = 'touch';
                    // 移除固定定位，保持正常滚动
                }
                
                // 微信JS-SDK准备
                document.addEventListener('WeixinJSBridgeReady', function() {
                    console.log('微信JS-SDK准备就绪');
                    safeDebugInfo('微信JS-SDK准备就绪');
                    if (typeof WeixinJSBridge !== 'undefined') {
                        WeixinJSBridge.call('hideOptionMenu');
                        WeixinJSBridge.call('showOptionMenu');
                    }
                });
                
                // 延迟初始化
                setTimeout(function() {
                    console.log('微信浏览器延迟初始化');
                    safeDebugInfo('微信浏览器延迟初始化');
                    if (typeof initializeNavigation === 'function') {
                        initializeNavigation();
                        safeDebugInfo('导航初始化完成');
                    }
                    if (typeof initializeFilters === 'function') {
                        initializeFilters();
                        safeDebugInfo('筛选器初始化完成');
                    }
                    if (typeof loadCharacters === 'function') {
                        loadCharacters('9');
                        safeDebugInfo('角色加载完成');
                    }
                }, 1000);
            }
            
            // 页面加载完成后的处理
            window.addEventListener('load', function() {
                console.log('页面加载完成');
                safeDebugInfo('页面完全加载完成');
                
                // 新用户特殊处理
                if (isNewUser) {
                    safeDebugInfo('新用户页面加载完成，等待初始化');
                    // 新用户给更多时间加载
                    setTimeout(function() {
                        checkPageContent();
                    }, 4000);
                } else {
                    // 老用户正常检查
                    setTimeout(function() {
                        checkPageContent();
                    }, 3000);
                }
            });
            
            // 检查页面内容函数
            function checkPageContent() {
                var contentSections = document.querySelectorAll('.content-section');
                var hasContent = false;
                var retryCount = parseInt(localStorage.getItem('retryCount') || '0');
                
                for (var i = 0; i < contentSections.length; i++) {
                    if (contentSections[i].children.length > 1) {
                        hasContent = true;
                        break;
                    }
                }
                
                if (!hasContent) {
                    safeDebugInfo('页面内容加载失败，重试次数: ' + retryCount);
                    
                    // 限制重试次数，避免无限循环
                    if (retryCount < 3) {
                        retryCount++;
                        localStorage.setItem('retryCount', retryCount.toString());
                        safeDebugInfo('准备第' + retryCount + '次重试');
                        
                        // 延迟重试
                        setTimeout(function() {
                            safeDebugInfo('执行第' + retryCount + '次重试');
                            initializePageFunctions();
                            checkPageContent();
                        }, 2000);
                    } else {
                        safeDebugInfo('重试次数已达上限，建议手动刷新');
                        // 重置重试计数
                        localStorage.removeItem('retryCount');
                    }
                } else {
                    safeDebugInfo('页面内容加载正常');
                    // 重置重试计数
                    localStorage.removeItem('retryCount');
                    
                    if (isWeChat) {
                        setTimeout(function() {
                            console.log('内容区域数量:', contentSections.length);
                            safeDebugInfo('内容区域数量: ' + contentSections.length);
                            for (var i = 0; i < contentSections.length; i++) {
                                console.log('区域', i, ':', contentSections[i].id, '显示状态:', contentSections[i].style.display);
                                safeDebugInfo('区域' + i + ': ' + contentSections[i].id + ' 显示状态: ' + contentSections[i].style.display);
                            }
                        }, 2000);
                    }
                }
            }
        })();
        
        // 调试功能
        function addDebugInfo(message) {
            var debugContent = document.getElementById('debug-content');
            if (debugContent) {
                var time = new Date().toLocaleTimeString();
                debugContent.innerHTML += '<div>[' + time + '] ' + message + '</div>';
                console.log('[' + time + '] ' + message);
            }
        }
        
        function toggleDebug() {
            var debugInfo = document.getElementById('debug-info');
            if (debugInfo.style.display === 'none') {
                debugInfo.style.display = 'block';
            } else {
                debugInfo.style.display = 'none';
            }
        }
        

        
        function forceRefresh() {
            if (typeof addDebugInfo === 'function') {
                addDebugInfo('执行强制刷新');
            }
            // 清除所有缓存
            localStorage.clear();
            sessionStorage.clear();
            if ('caches' in window) {
                caches.keys().then(function(names) {
                    for (var i = 0; i < names.length; i++) {
                        caches.delete(names[i]);
                        if (typeof addDebugInfo === 'function') {
                            addDebugInfo('清除缓存: ' + names[i]);
                        }
                    }
                });
            }
            
            // 通知Service Worker清除缓存
            if ('serviceWorker' in navigator && navigator.serviceWorker.controller) {
                navigator.serviceWorker.controller.postMessage({
                    type: 'CLEAR_CACHE'
                });
                if (typeof addDebugInfo === 'function') {
                    addDebugInfo('通知Service Worker清除缓存');
                }
            }
            
            // 强制刷新页面
            window.location.reload(true);
        }
        
        // 缓存管理功能
        function clearAllCaches() {
            if (typeof addDebugInfo === 'function') {
                addDebugInfo('清除所有缓存');
            }
            return new Promise(function(resolve) {
                // 清除localStorage和sessionStorage
                localStorage.clear();
                sessionStorage.clear();
                
                // 清除Service Worker缓存
                if ('caches' in window) {
                    caches.keys().then(function(names) {
                        var promises = names.map(function(name) {
                            return caches.delete(name);
                        });
                        Promise.all(promises).then(function() {
                            if (typeof addDebugInfo === 'function') {
                                addDebugInfo('所有缓存已清除');
                            }
                            resolve();
                        });
                    });
                } else {
                    resolve();
                }
            });
        }
        
        // 检查缓存状态
        function checkCacheStatus() {
            if (typeof addDebugInfo === 'function') {
                addDebugInfo('检查缓存状态');
            }
            if ('caches' in window) {
                caches.keys().then(function(names) {
                    if (typeof addDebugInfo === 'function') {
                        addDebugInfo('当前缓存数量: ' + names.length);
                    }
                    for (var i = 0; i < names.length; i++) {
                        if (typeof addDebugInfo === 'function') {
                            addDebugInfo('缓存: ' + names[i]);
                        }
                        caches.open(names[i]).then(function(cache) {
                            cache.keys().then(function(requests) {
                                if (typeof addDebugInfo === 'function') {
                                    addDebugInfo('缓存内容数量: ' + requests.length);
                                }
                            });
                        });
                    }
                });
            }
            
            // 检查Service Worker状态
            if ('serviceWorker' in navigator) {
                navigator.serviceWorker.getRegistrations().then(function(registrations) {
                    if (typeof addDebugInfo === 'function') {
                        addDebugInfo('Service Worker数量: ' + registrations.length);
                    }
                    for (var i = 0; i < registrations.length; i++) {
                        if (typeof addDebugInfo === 'function') {
                            addDebugInfo('SW状态: ' + (registrations[i].active ? 'active' : 'inactive'));
                        }
                    }
                });
            }
        }
    </script>
</body>
</html>
